import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;

public class TestRandom {


    public static void main(String[] args) {
        for (int d = 0; d < 5; d++) {
            List<String> list = new ArrayList<>();
            Random random = new Random();
            long start = System.currentTimeMillis();
            for (int i = 1; i < 50000; i++) {
                int x = random.nextInt(i);
                list.add(x, "a");
            }
            long end = System.currentTimeMillis();
            System.out.println("arrayList insert time " + (end - start));


            LinkedList<String> list1 = new LinkedList<>();
            start = System.currentTimeMillis();
            for (int i = 1; i < 50000; i++) {
                int x = random.nextInt(i);
                list1.add(x, "a");
            }
            end = System.currentTimeMillis();
            System.out.println("LinkedList insert time " + (end - start));
            System.out.println();
        }
    }
}
